package com.wilson.treeviewer.db;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import com.wilson.treeviewer.model.User;

public class UserDB {

    private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("UserService");

    public static EntityManagerFactory getEntityManagerFactory() {
        return emf;
    }

    private final EntityManager em = emf.createEntityManager();

    public List<User> getUsers() {
        List<User> users = em.createQuery("from User", User.class).getResultList();
        return users;
    }

}
